#pragma once

#define HDEF_NATIVE_CPU_NR	16
#define HDEF_CYCLE_FREQ_PERNS	(3.6)
#define APDS_CPU_NR		(HDEF_NATIVE_CPU_NR)

#define APDS_MAX_THREADS	(256)
#define APDS_MAX_SERVER		(1)
#define APDS_HELP_QUOTA		(APDS_CPU_NR >> 1)


#define APDS_NUMA_NR		(2)
#define APDS_NUMA_CORENR	(8)

#define APDS_HELP_INCR_P	(0)

__attribute__((aligned(64))) static const unsigned char eff_quota_3700x[APDS_CPU_NR] = {
	/* numa 0 */
	APDS_HELP_QUOTA + APDS_HELP_INCR_P, APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1),
	/* numa 1 */
	APDS_HELP_QUOTA + APDS_HELP_INCR_P, APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1),
	/* numa 0 smt */
	APDS_HELP_QUOTA + APDS_HELP_INCR_P, APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1),
	/* numa 1 smt */
	APDS_HELP_QUOTA + APDS_HELP_INCR_P, APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1), APDS_HELP_QUOTA - (APDS_HELP_INCR_P >> 1)};

/* 0-3 -> numa 0; 4-7 -> numa 1; 8-11 -> numa 0; 12 - 15 -> numa1*/
#define APDS_GET_NUMANODES(cid)		(((cid) & (APDS_NUMA_CORENR - 1)) >> 2)
#define APDS_GET_COREQUOTA(cid)		(eff_quota_3700x[cid])
#define APDS_GET_COREEFF(cid)		(eff_quota_3700x[cid])
#define APDS_GET_NUMAEFF(cid, tcid)	(numa_eff_targetincr_quota_3700x[cid][tcid])
#define SMT_EFF_DECR			(unsigned char)2
#define APDS_NUMA_EFF_DEC		(0)
/* 目标是尽量在同一numa核内转移 */
/* 避免随机放弃的情况 */


/* 再弄个numa eff下降 */
static const unsigned char numa_eff_targetincr_quota_3700x[APDS_CPU_NR][APDS_CPU_NR] = {
    /* core 0 */
    { 0,0,0,0, 1,1,1,1, SMT_EFF_DECR,0,0,0, 1,1,1,1}, 
    /* core 1 */
    { 0,SMT_EFF_DECR,0,0, 1,1,1,1, 0,SMT_EFF_DECR,0,0, 1,1,1,1}, 
    /* core 2 */
    { 0,0,SMT_EFF_DECR,0, 1,1,1,1, 0,0,SMT_EFF_DECR,0, 1,1,1,1}, 
    /* core 3 */
    { 0,0,0,SMT_EFF_DECR, 1,1,1,1, 0,0,0,SMT_EFF_DECR, 1,1,1,1}, 

    /* core 4 */
    { 1,1,1,1, SMT_EFF_DECR,0,0,0, 1,1,1,1, SMT_EFF_DECR,0,0,0}, 
    /* core 5 */
    { 1,1,1,1, 0,SMT_EFF_DECR,0,0, 1,1,1,1, 0,SMT_EFF_DECR,0,0}, 
    /* core 6 */
    { 1,1,1,1, 0,0,SMT_EFF_DECR,0, 1,1,1,1, 0,0,SMT_EFF_DECR,0}, 
    /* core 7 */
    { 1,1,1,1, 0,0,0,SMT_EFF_DECR, 1,1,1,1, 0,0,0,SMT_EFF_DECR}, 

    /* core 8 */
    { SMT_EFF_DECR,0,0,0, 1,1,1,1, SMT_EFF_DECR,0,0,0, 1,1,1,1}, 
    /* core 9 */
    { 0,SMT_EFF_DECR,0,0, 1,1,1,1, 0,SMT_EFF_DECR,0,0, 1,1,1,1}, 
    /* core 10 */
    { 0,0,SMT_EFF_DECR,0, 1,1,1,1, 0,0,SMT_EFF_DECR,0, 1,1,1,1}, 
    /* core 11 */
    { 0,0,0,SMT_EFF_DECR, 1,1,1,1, 0,0,0,SMT_EFF_DECR, 1,1,1,1}, 

    /* core 12 */
    { 1,1,1,1, SMT_EFF_DECR,0,0,0, 1,1,1,1, SMT_EFF_DECR,0,0,0}, 
    /* core 13 */
    { 1,1,1,1, 0,SMT_EFF_DECR,0,0, 1,1,1,1, 0,SMT_EFF_DECR,0,0}, 
    /* core 14 */
    { 1,1,1,1, 0,0,SMT_EFF_DECR,0, 1,1,1,1, 0,0,SMT_EFF_DECR,0}, 
    /* core 15 */
    { 1,1,1,1, 0,0,0,SMT_EFF_DECR, 1,1,1,1, 0,0,0,SMT_EFF_DECR}
};